package com.bjnangle.nangletool;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends BaseActivity implements View.OnClickListener{
    private Context context = MainActivity.this;
    private TextView tvTitle;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ((Button)findViewById(R.id.btn_key_test)).setOnClickListener(this);
        ((Button)findViewById(R.id.btn_version)).setOnClickListener(this);
        ((Button)findViewById(R.id.btn_tts)).setOnClickListener(this);
        ((Button)findViewById(R.id.btn_voice)).setOnClickListener(this);
        ((Button)findViewById(R.id.btn_speak)).setOnClickListener(this);
        ((Button)findViewById(R.id.btn_net)).setOnClickListener(this);
        ((Button)findViewById(R.id.btn_about)).setOnClickListener(this);
        setActivity(this);
        ivGoBack = (ImageView)findViewById(R.id.btn_back);
        tvTitle = (TextView)findViewById(R.id.tv_title);
        tvTitle.setText("测试工具");

    }

    @Override
    protected void onResume() {
        super.onResume();
        ivGoBack.setVisibility(View.GONE);
    }

    @Override
    public void onClick(View view) {
        Intent intent = new Intent();
        switch (view.getId()){
            case R.id.btn_key_test:
                intent.setClass(context,KeyTestActivity.class);
                break;
            case R.id.btn_version:
                intent.setClass(context,VersionActivity.class);
                break;
            case R.id.btn_tts:
                intent.setClass(context,TTSActivity.class);
                break;
            case R.id.btn_voice:
                intent.setClass(context,VoiceActivity.class);
                break;
            case R.id.btn_speak:
                intent.setClass(context,SpeakActivity.class);
                break;
            case R.id.btn_net:
                intent.setClass(context,NetActivity.class);
                break;
            case R.id.btn_about:
                intent.setClass(context,AboutActivity.class);
                break;
            default:
                break;
        }
        startActivity(intent);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Intent intent = new Intent();
        switch (keyCode){
            case KeyEvent.KEYCODE_1:
                intent.setClass(context,KeyTestActivity.class);
                startActivity(intent);
                break;
            case KeyEvent.KEYCODE_2:
                intent.setClass(context,VersionActivity.class);
                startActivity(intent);
                break;
            case KeyEvent.KEYCODE_3:
                intent.setClass(context,TTSActivity.class);
                startActivity(intent);
                break;
            case KeyEvent.KEYCODE_4:
                intent.setClass(context,VoiceActivity.class);
                startActivity(intent);
                break;
            case KeyEvent.KEYCODE_5:
                intent.setClass(context,SpeakActivity.class);
                startActivity(intent);
                break;
            case KeyEvent.KEYCODE_6:
                intent.setClass(context,NetActivity.class);
                startActivity(intent);
                break;
            case KeyEvent.KEYCODE_7:
                intent.setClass(context,AboutActivity.class);
                startActivity(intent);
                break;
//            case KeyEvent.KEYCODE_8:
//                break;
//            case KeyEvent.KEYCODE_9:
//                break;
//            case KeyEvent.KEYCODE_0:
//                break;
        }

        return super.onKeyDown(keyCode, event);

    }
}
